package com.shuai.frame.config;

import com.shuai.frame.constant.LoadBalancerKeys;
import com.shuai.frame.constant.RetryStrategyKeys;
import com.shuai.frame.constant.SerializerConstant;
import com.shuai.frame.constant.TolerantStrategyKeys;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class XSRpcConfig {

    private String name;
    private String version;
    private String serverAddress;

    {
        try {
            serverAddress = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }

    private Integer serverPort = 12400;
    private Boolean mock = false;   // 默认不开启mock
    private String serializer = SerializerConstant.JDK_SERIALIZER;  // 默认使用JDK序列化器
    private String loadBalancer = LoadBalancerKeys.ROUND_ROBIN; // 默认使用轮询负载均衡算法
    private String retryStrategy = RetryStrategyKeys.NO_RETRY;  // 默认请求失败不重试
    private String tolerateStrategy = TolerantStrategyKeys.FAIL_FAST; // 默认容错策略为快速失败
    private XsRPCRegistryCenterConfig registryCenterConfig = new XsRPCRegistryCenterConfig(); // 注册中心配置
}

